<?php

/*
 * @author Ebrain Cedeno <ebraincedeno@gmail.com>
 */

class TEdit extends TWidget{
    
    public $Text;
    public $Type="text";
    public $ReadOnly = false;
    public $Disabled = false;
    
    public function __construct() {
        parent::__construct(__CLASS__);
        $this->Width = 200;
        $this->Height = 25;
    }

    protected  function getReadOnly(){
        if ($this->ReadOnly == true){
            return 'readOnly="true"'; 
        }
        else{
            return '';
        }
        
    }

    protected function getDisabled(){
        if ($this->Disabled == true){
            return 'disabled';
        }
        else{
            return '';
        }
        
    }

    public function show(){
        
        if (!array_key_exists('style', $this->OptionsAditional)){
            $this->OptionsAditional['style'] = array('width:'.$this->Width.'px','height:'.$this->Height.'px');
        }
        else{
            $this->OptionsAditional['style'][] = 'width:'.$this->Width.'px';
            $this->OptionsAditional['style'][] = 'height:'.$this->Height.'px';
        }
        
        if ($this->Visible == true){
            $html = '<input name="'.$this->Name.'" id="'.$this->Id.'" type="'.$this->Type.'" value="'.$this->Text.'" '.$this->getOptionsAditional().' '.$this->getReadOnly().' '.$this->getDisabled().' />';
            return $html;
        }
    }
    
}
?>